﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Core.Specification;
using Domain.MainModule.Entities;

namespace Domain.MainModule.Customers
{
    public class CustomerMembershipUserIdSpecification: Specification<Customer>
    {
        Guid _MembershipUserId;

        public CustomerMembershipUserIdSpecification(Guid userId)
        {
            this._MembershipUserId = userId;
        }

        public override System.Linq.Expressions.Expression<Func<Customer, bool>> SatisfiedBy()
        {
            Specification<Customer> spec = new TrueSpecification<Customer>();

            spec &= new DirectSpecification<Customer>(t => t.IsEnabled);

            spec &= new DirectSpecification<Customer>(c => c.MembershipUserId == this._MembershipUserId);

            return spec.SatisfiedBy();
        }
    }
}
